import request from '@/utils/request'

export default {
  getRoutelistList(searchModel) {
    let params = '&pageNo=' + searchModel.pageNo + '&pageSize=' + searchModel.pageSize
    params =
      searchModel.name === '' ||
      searchModel.name === null ||
      searchModel.name === undefined
        ? params
        : params + '&name=' + searchModel.name
    return request({
      url: '/routelist/list?' + params,
      method: 'get'

      // params:{
      //   pageNo:searchModel.pageNo,
      //   pageSize:searchModel.pageSize,
      //   name:searchModel.name,
      // }
    })
  },
  addRoutelist(routelist) {
    return request({
      url: '/routelist/addRoutelist',
      method: 'post',
      data: routelist
    })
  },
  updateRoutelist(routelist) {
    return request({
      url: '/routelist/updateRoutelist',
      // method: 'put',
      method: 'post',
      data: routelist
    })
  },
  saveRoutelist(routelist) {
    if (routelist.routelistId == null || routelist.routelistId === undefined) {
      return this.addRoutelist(routelist)
    }
    return this.updateRoutelist(routelist)
  },
  getRoutelistById(routelistId) {
    return request({
      // url: '/routelist/'+id,
      url: `/routelist/getRoutelistById/${routelistId}`,
      method: 'get'
    })
  },
  deleteById(routelistId) {
    return request({
      url: `/routelist/deleteRoutelistById`,
      method: 'delete',
      params: {
        deleteRoutelistId: routelistId
      }
    })
  }

}
